import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue';
import Mine from '../views/Mine.vue';
const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta:{title:'首页'}
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue')
  },
  {
    path: '/mine',
    name: 'Mine',
    component: Mine,
    children:[
      {path:'/mine',redirect:'/mine/msg'},
      {path:'msg',component:()=>import('../views/Msg.vue')},
      {path:'order',component:()=>import('../views/Order.vue')},
    ],
    meta:{title:'我的'}
  },
  {
    path:'/circle',
    name:'Circle',
    component: () => import('../views/Circle.vue')
  },
  {
    path:'/todolist',
    name:'ToDoList',
    component:()=>import('../views/ToDoList.vue')
  },
  {
    path:'/news/:id',
    name:'News',
    component:()=>import('../views/News.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  linkActiveClass:'current'
})
router.beforeEach((to,from,next)=>{
  console.log('from',from);
  console.log('to',to);
  document.title=to.meta.title
  next()
})

export default router
